package com.cuit.controller;


import com.cuit.domain.File;
import com.cuit.domain.Result;
import com.cuit.service.impl.FileServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/view")
public class ViewFilesController {
    @Autowired
    private FileServiceImpl fileService;

    @GetMapping("/image/{userId}")
    public List<File> ViewImage(@PathVariable int userId,Model model){
        List<File> files = fileService.ViewImage(1);
        model.addAttribute("files",files);
        return files;
    }

    @GetMapping("/video/{id}")
    public List<File> ViewVideo(@PathVariable int userId, Model model){
        List<File> files = fileService.ViewVideo(userId);
        return files;
    }
    @GetMapping("/music/{id}")
    public List<File> ViewMusic(@PathVariable int userId, Model model){
        List<File> files = fileService.ViewMusic(userId);
        return files;
    }

}